<?php
/**
 * User: YL
 * Date: 2019/6/10
 */

namespace restful\utils;

use Predis\Client;
use restful\traits\InstanceTrait;

class Redis
{
    use InstanceTrait;

    protected $options;
    protected $connect;

    private function __construct()
    {
        $this->options = Env::get('redis');
        $this->connect = new Client($this->options, [
            'prefix' => $this->getPrefix(),
        ]);
    }

    /**
     * getConnect
     * @return Client
     */
    public function getConnect()
    {
        return $this->connect;
    }

    /**
     * getPrefix
     * @return string
     */
    public function getPrefix()
    {
        return $this->options['prefix'] ?? '';
    }
}